<?php

/**
 * 公共widget
 *
 * @author kj
 */

namespace Kj\Admin\Html;

use View;
use Kj\Admin\Libraries\SwfUpload;

class Common
{
    /**
     * 初始化
     *
     * @access public
     */
    public function __construct()
    {
        //todo
    }
    
    /**
     * 树形结构所需的js,css
     *
     * @access public
     */
    public function treeviewResources()
    {
        return View::make('admin/widget/treeview');
    }

    /**
     * 输入上传图片按钮，调用上传窗口
     * 
     * @param int $id 表单id
     * @param int $submit_images 回调函数
     * @param string $alowexts 允许图片格式
     * @param array $nums 最多可以上传多少个文件 
     * @param array $thumb_setting 
     * @param int $watermark_setting  0或1
     */
    public function swfUploadButton($id, $submit_images = 'submit_images', $alowexts = '', $nums = 8, $thumb_setting = array(), $watermark_setting = 0 )
    {
        if(!empty($thumb_setting) && count($thumb_setting)) $thumb_ext = $thumb_setting[0].','.$thumb_setting[1];
        else $thumb_ext = ',';
        if(!$alowexts) $alowexts = 'jpg|jpeg|gif|bmp|png';
        $str = '';
        $swfupload = new SwfUpload("$nums,$alowexts,1,$thumb_ext,$watermark_setting");
        $authkey = $swfupload->uploadKey();
        return $str."<a class=\"btn\" id=\"swf-upload-btn\" style=\"font-size: 12px;\" onclick=\"javascript:flashupload('{$id}_dialog', '附件上传','{$id}',{$submit_images},'{$nums},{$alowexts},1,{$thumb_ext},{$watermark_setting}','{$authkey}')\" />附件上传</a>";
    }

}
